<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/jsplib/pubhead.jsp"%>
<%@ page import="net.comm.common.ValueMaping" %>
<%@ taglib uri="/WEB-INF/myTaglib.tld" prefix="tag"%>
<%@ taglib uri="/WEB-INF/jstlfun.tld" prefix="myfn" %>
<%@ taglib uri="/WEB-INF/c.tld"  prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="x-ua-compatible" content="ie=7" />
	<TITLE>上传照片:i友邻社区</TITLE>
	<link rel="stylesheet" type="text/css" href="${cpath}/css/main.css" />
	<link rel="stylesheet" type="text/css" href="${cpath}/css/leftmenu.css" />
	<link rel="stylesheet" type="text/css" href="${cpath}/css/layout.css">
	<link rel="stylesheet" type="text/css" href="${cpath}/css/group.css" />
	<script type="text/javascript" src="${cpath}/js/global.js"></script>
	
</head>
<body>
<script> 
	//转页面
	var curUserID = '${userID}';
	if((curUserID == "")||(curUserID == null)){
//		parent.window.location.replace("${cpath}/index.jsp"); 
	}
	var more_pic = 5;
	if(more_pic < 0){more_pic = 0;}
</script>

 	<!-- 页首 {{{ -->
	<%@ include file="/menu.jsp"%>
   
	<div id="mainBody">
	<!-- 左边菜单栏 {{{ -->
	<%@ include file="/leftmenu.jsp"%>

		<DIV id=group>
		<!-- 右侧宽栏 {{{ -->
		<DIV class=group_mid>

			<div class='subtop' >
					<p><a href="#"><img src="${cpath}/${myfn:getGroupPic(theForm.groupID)}" ></a></p>
				<dl >
						<dt class="tit"><a href="${cpath}/group.do?action=get&groupID=${theForm.groupID}">${myfn:getGroupName(theForm.groupID)}</a>&gt;<a >照片区</a></dt>
						<dd class="intro">&nbsp;</dd>
				</dl>
				<div class='fun'>
					<li><a href="javascript:history.go(-1);">返回上一页</a></li>
				</div>
			</div>
			<div id="section-header">
					<ul class="related-links" style="float:left">
						<li><a href="${cpath}/qunzu_${albumForm.groupID}/xiangce_${theForm.GAlbumID}">返回该专辑</a></li>
					</ul>
			</div>
			<DIV class='whole'><!-- 右侧宽栏 }}}-->
	
				<div class='bigpic' >
					<dl >
						<form  name="frm_upload" action="${cpath}/gpicture.do?action=add"  method="post"  enctype="multipart/form-data">
						<dt class="tit"><span>请选择相册：</span>
							<select name="GAlbumID" value="${theForm.GAlbumID}">
							<c:forEach var="album" items="${albumlist}" varStatus="status">   
								<option value="${album.GAlbumID}" >${album.albumname}</option>
							</c:forEach> 		
							</select>
						</dt>
						<dd class="info">请选择要上传的照片：
							<INPUT id=max_file_size type=hidden value=2048152 name=MAX_FILE_SIZE>
							<IMG id=oFileChecker style="WIDTH: 0px; HEIGHT: 0px" onload=check_photo_size()> 
							<TABLE id=file_table>
								<SCRIPT type=text/javascript>
									function add_file_item()
									{
										var oTable = document.getElementById("file_table");
										if (oTable.rows.length >= more_pic) {
											if (more_pic == 0) {
												alert("每人最多可以上传"+more_pic+"张，您已经上传了"+more_pic+"张照片");
											} else {
												alert("同时最多可以上传"+more_pic+"张照片");
											}
											return;
										 }
										 var oTr = oTable.insertRow(oTable.rows.length);
										 var oTd = oTr.insertCell(0);
										 var htmlStr = '<input type="file" name="upFile[]" id="upFile_11" style="width:220px;height:25px" onchange="check_fileszie(this);" />';
										 htmlStr += '&emsp;<input type="button" value="取消" onclick="del_file_item(event)" />&emsp;';
										 htmlStr += '<em onclick="add_file_item()" style="cursor:pointer; font-style:normal; border-bottom:1px solid #014391; color:#014391;">上传更多</em><span><br /><br /></span>';
										 oTd.innerHTML = htmlStr; 
										 hidden_upside_file_more();
									 }
									 function hidden_upside_file_more()
									 {
										 var oTable = document.getElementById("file_table");
										 var oldIndex = oTable.rows.length-2 > 0 ? oTable.rows.length-2 : 0;
										 var oAOld = oTable.rows[oldIndex].firstChild.lastChild.previousSibling;
										 oAOld.style.display = "none";
									 }
									 function show_upside_file_more()
									 {
										 var oTable = document.getElementById("file_table");
										 var oldIndex = oTable.rows.length-1 > 0 ? oTable.rows.length-1 : 0;
										 var oAOld = oTable.rows[oldIndex].firstChild.lastChild.previousSibling;
										 oAOld.style.display = "";
										}
										function del_file_item(e)
										{
											 if (window.event) {
													 e = window.event;
													 e_src = e.srcElement;   
											 } else {
													 e_src = e.target;
											 }
											 document.getElementById('file_table').deleteRow(e_src.parentNode.parentNode.rowIndex);   
											 show_upside_file_more();
										}
								</SCRIPT>
								<TBODY>
								<TR>
									<TD>
								<INPUT id=upFile_11 style="WIDTH: 220px; HEIGHT: 25px" type=file onchange="javascript:check_fileszie(this);" name=upFile[]>
								<EM style="CURSOR: pointer; COLOR: #014391; BORDER-BOTTOM: #014391 1px solid; FONT-STYLE: normal" 
										onclick=add_file_item()>上传更多</EM>
										<SPAN><BR><BR></SPAN></TD></TR></TBODY></TABLE>&nbsp;&nbsp;
								<INPUT id=submit_photo type=image src="${cpath}/images/btn04_usercpphoto.jpg" onclick="upload_photo();">

						</dd>
						<dd class="info">
							<FONT color=red>严禁上传色情、暴力、恐怖、反动等违法照片，如果您的照片被会员投诉为上述照片，经查实会将您列入网站黑名单，以后都将无法注册和登录网站！</FONT><BR>*支持格式：jpg、jpeg、gif。<BR>* 上传照片，每张大小不要超过2M。<BR>* 同时最多可以上传&nbsp;<STRONG>5</STRONG>&nbsp;张照片。
							<!--隐藏域-->
							<input type="hidden" name='descr0' value=''/>
							<input type="hidden" name='descr1' value=''/>
							<input type="hidden" name='descr2' value=''/>
							<input type="hidden" name='descr3' value=''/>
							<input type="hidden" name='descr4' value=''/>
							<input type="hidden" name='type'	 value='2'/>
							<input type="hidden" name='isHead' value='2'/>
							<input type="hidden" name='userID' value='${userID}'/>
							<input type="hidden" name='groupID' value='${theForm.groupID}'/>
						</dd>
						</form>
					</dl>
				</div>
			</div>			

		</DIV><!-- profile_mid }}} -->
		</DIV><!-- group end }}} -->
	<DIV class="clear"></DIV>
	<%@ include file="/indexfoot.jsp"%>
	</DIV><!--mainBody end-->
	<!--页尾 -->
</body>
</html>
<!---->
<SCRIPT type=text/javascript>

	function my_getbyid(id)
	{

		 itm = null;
		 if (document.getElementById)
		 {
				itm = document.getElementById(id);
		 }
		 else if (document.all)
		 {
				itm = document.all[id];
		 }
		 else if (document.layers)
		 {
				itm = document.layers[id];
		 }
		 
		 return itm;
	}

	function check_photo_size()
	{
			img_temp = my_getbyid('oFileChecker');
			var limit = parseInt(my_getbyid('max_file_size').value);
			if (img_temp.fileSize > limit) {
					alert("照片文件过大，请选择2M以下的文件上传");
					return false;
			}
	}
	function check_fileszie(filePicker)
	{
			var patn = /.jpg$|.jpeg$|.gif$/i;  
			if(patn.test(filePicker.value)) {
					img_temp = my_getbyid('oFileChecker');
					img_temp.src = filePicker.value;
			} else {
						alert('您选择的不是合法的图片文件,支持文件格式：.jpg/.jpeg/.gif，请重新选择');
						filePicker.value='';
						return false;
			}
			return true;
	}	

	function upload_photo()
	{

			if(more_pic == 0) { 
					alert("照片数量已达规定张数，请至少删除1张之后再上传");
					return false;
			}
			var nopic = 0;
			var oP, haveP=0;
			var patn = /.jpg$|.jpeg$|.gif$/i;  
			var files = document.getElementsByName('upFile[]');
			for (var i=0,j=0; i < files.length; i++) {
					if (files[i].value.length > 1) {
							haveP = 1;
							if(!patn.test(files[i].value)) {
									j = i+1;
									alert('第'+j+'个不是合法的图片文件,支持文件格式：.jpg/.jpeg/.gif，请重新选择');
									return false;
							}
							nopic = i; 
							files[i].name = "upFile"+ nopic;
					}
			}
			if (haveP == 0) {
					alert("请选择要上传的照片");
					return false;
			}

			var form = document.frm_upload;

			my_getbyid('submit_photo').src ='${cpath}/images/upload.gif'
			my_getbyid('submit_photo').onclick = "";

			form.submit();
	}

</script>
